# import matplotlib.pyplot as plt
# import numpy as np
#
# # 生成一个二维随机数组
# img = np.random.rand(10, 10)
#
# # 绘制灰度图像
# plt.imshow(img, cmap='gray')
#
# # 显示图像
# plt.show()
from configparser import Interpolation

# import matplotlib.pyplot as plt
# import numpy as np
#
# # 生成一个随机的彩色图像[三通道]
# img = np.random.rand(10, 10, 3)
#
# # 绘制彩色图像
# plt.imshow(img)
#
# # 显示图像
# plt.show()

# import matplotlib.pyplot as plt
# import numpy as np
#
# img = np.random.rand(10, 10)
# plt.imshow(img, cmap = 'hot')
# plt.colorbar(label='hot')
#
# plt.show()

# import matplotlib.pyplot as plt
# import numpy as np
# from PIL import Image
#
# img = Image.open(r"D:\l'j't\code\pycharm\learning-python\AI\images\map.jpg")
#
# # 转换为数组
# # data = np.array(img)
#
# # 绘制地图
# plt.imshow(img)
#
# # 隐藏坐标轴
# plt.axis('off')
#
# # 显示图像
# plt.show()

import numpy as np
import matplotlib.pyplot as plt

n = 5

img = np.reshape(np.linspace(0, 1, n ** 2), (n, n))
# img = np.random.rand(10, 10)
fig, axes = plt.subplots(1, 3, sharey=True)

# fig.suptitle("Test")

# nearest[最近邻插值]  bilinear[双线性插值] bicubic[双三次插值]
axes[0].imshow(img, cmap="gray", interpolation="nearest")
axes[0].set_xticks(range(n))
axes[0].set_yticks(range(n))
axes[0].set_title("gray + nearest")

axes[1].imshow(img, cmap="viridis", interpolation="nearest")
axes[1].set_xticks(range(n))
axes[1].set_title("viridis + nearest")

axes[2].imshow(img, cmap="viridis", interpolation="bicubic")
axes[2].set_xticks(range(n))
axes[2].set_title("viridis + bicubic")

plt.tight_layout()
plt.show()